<?php
namespace app\api\controller;
use app\api\controller\Base;

class Activity extends Base
{
    /**
     * 获取id
     * @data pages  
     * @data limit
     * @return  array
     * 
     */
    public function list()
    {
        if(request()->isPost()){
            $pages = input('post.pages');
            $limet = input('post.limit');
            if(!isset($pages)){
               $pages=1;
            }
            if(!isset($limet)){
                $limet = 10;
            }
            $list = model('ActivityModel')->list($limet,$pages);
            $list = model('ActivityModel')->cate($list);
            $data =  model('Res')->ctx($list);
            foreach ($data['data'] as $i => $item) {
                $data['data'][$i]['start_time'] = date('Y-m-d',$item['start_time']);
                $data['data'][$i]['end_time'] = date('Y-m-d',$item['end_time']);
            }
            $data['pages'] = $pages;
            $data['limet'] = $limet;
            return $data;
        }else{
            return model('Res')->noPost();
        }
        
    }
    public function info()
    {
        if(request()->isPost()){
            $id = input('post.id');
            if(isset($id)){
                $list = model('ActivityModel')->info($id);

                return model('Res')->ctx($list);
            }else{
                return model('Res')->noParam();
            }
        }else{
            return model('Res')->noPost();
        }
    }
}
